package BehavioralPattern.Memento;

public class Client {
    public static void main(String[] args) {
        // 完成一步悔棋
        MementoCaretaker mementoCaretaker = new MementoCaretaker();
        Chessman chessman = new Chessman("车",1,1);
        display(chessman);
        mementoCaretaker.setMemento(chessman.save());
        chessman.setY(4);
        display(chessman);
        mementoCaretaker.setMemento(chessman.save());
        chessman.setX(5);
        display(chessman);
        System.out.println("*************悔棋**************");
        chessman.restore(mementoCaretaker.getMemento());
        display(chessman);
    }

    public static void display(Chessman chess) {
        System.out.println("棋子" + chess.getLabel() + "当前位置为：" + "第" + chess.getX() + "行" + "第" + chess.getY() + "列。");
    }
}
